package com.ejkj.pdf;

import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;


import java.util.HashMap;
import java.util.Map;

/**
 * @ClassName SpringBootPdfDemo
 * @Description TODO
 * @Author skies
 * @Date 2021/2/8 15:00
 * @Version 1.0
 */
@SpringBootTest(classes = {PdfConfiguration.class})
public class SpringBootPdfDemo {

	private static final Logger logger = LoggerFactory.getLogger(SpringBootPdfDemo.class);

	@Autowired
	PdfService pdfService;

	@Test
	public void signTest() throws Exception {
		byte[] b = pdfService.getPdfbytes();
		System.out.println();
	}

	@Test
	public void paramsTest() throws Exception {
		PdfProperties pdfProperties = new PdfProperties();

		// 以下参数 可配置在application配置文件中
		pdfProperties.setTemplate("pdf/template_test.pdf");//模板必填
		pdfProperties.setParams(getData());// 参数map必填
//		pdfProperties.setFont();//字体非必填
//		pdfProperties.setFontSize();//字号非必填
//		pdfProperties.setSignImg();//签名图片，三要素之一
//		pdfProperties.setKey();//签名证书，三要素之一
//		pdfProperties.setPassword();//证书密码，三要素之一
//		pdfProperties.setImgs();//图片填充必填 图片参数需为base64字符串
		byte[] b = pdfService.getPdfbytes(pdfProperties);
	}

	public Map<String, String> getData() {
		Map<String, String> params = new HashMap<String, String>();
		params.put("Text1", "中文1");
		params.put("Text2", "Text2");
		params.put("Text3", "Text3");
		params.put("Text4", "Text4");
		params.put("Text5", "Text5");
		params.put("Text6", "Text6");
		params.put("Text7", "Text7");
		return params;
	}


}
